<!DOCTYPE html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--><html lang="en"><!--<![endif]-->
<head>
<meta charset="utf-8">

<!-- Viewport Metatag -->
<!-- <meta name="viewport" content="width=device-width,initial-scale=1.0"> -->

<!-- Plugin Stylesheets first to ease overrides -->

<!-- Required Stylesheets -->
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/bootstrap/css/bootstrap.min.css" media="screen">

<script type="text/javascript" src="__PUBLIC__/js/jquery-2.1.4.min.js"></script>


<style type="text/css">


	body{

		width: 1200px;
		/*height: 300px;*/
	}

	#sel{

		width: 174px;
		
		
	}




</style>
</head>

<body>
	<center>
		<div class="all">
			<div class="container">
			<div class="row">
				<div class="col-md-10">
						<div class="panel panel-primary">
						  <div class="panel-heading">添加属性</div>
						  <div class="panel-body">
						   
						  </div>
						  	<form action="{:U('Admin/Attribute/insert')}" method="post" id="form1">
						  		<table class="table" id="myTable">
							<tr>
						   		<td></td>
							   	<th>父类名称：</th>
							   	<td>
							   	  <!--  <select class="form-control" id="sel" name="{$vo.id}">
                                            <option value='0'>请选择</option>
                                            	<foreach name="goodsclasses" item="vo" >
                                           		 	<option value="{$vo.id}">{$vo.type_name}</option>
                                            	</foreach>
                                    </select> -->

                                     <select name="type_id" class="small" size="" style="width:555px">
                                        <option>请选择</option>
                                        <foreach name="classes" item="vo">
                                            <optgroup label="{$key}" style="color:red;font-family:microsoft yahei">
                                                <foreach name="vo" item="v">
                                                    <option value='{$key}' style="color:#A29B9B">{$v}</option>
                                                </foreach>
                                            </optgroup>
                                        </foreach>
                                    </select>

							   	</td>
						   	</tr>
						  

								<tr>
						   		<td></td>
							   	<th>自定义属性名添加：</th>
							   	<td><input type="text" name="attr_name">&nbsp;&nbsp;&nbsp;&nbsp;<a  class="btn btn-primary addBtn">属性赋值</a></td>
						   	</tr>
	
							<input type="text" class="hidden" name = 'type_id' id="typd">
						  <tr id="myTr"></tr>
						  </table>
						   
						   		<button type="submit"  class="btn btn-primary">添加</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button class="btn btn-danger" id="btn1">重置</button>
						   		
						   	
						  	</form> 
						  </div>
				</div>
			</div>
		</div>
	</div>	
	</center>

		

</body>
</html>
<script>
	$(function(){

		// $('#btn1').click()
		// {

		// $('#form1')[0].reset();
		// }

		$('#sel').change(function()//JQ获取sel值后隐藏域传值
		{

			var typid 	= ($("select option:selected").val());

			$('#typd').val(typid);

			console.log($('#typd').val())

			
		});


		$("#myTable").delegate('a',"click",function(){

			  	$('#myTr').before($('<tr class = "btntr"><td></td><th>属性值:</th><td><input type="text" name = "attr_val[]">&nbsp;&nbsp;&nbsp;&nbsp;<a class="btn btn-primary addBtn"  >属性赋值</a>&nbsp;&nbsp;&nbsp;&nbsp;<button class="btn btn-danger cancel">删除</button></td></tr>'));

					return false;
			});



			$("#myTable").delegate('button',"click",function(){

			  		$(this).parent().parent().remove();

					return false;
			});



	

	})
</script>
